package de.islanders.world;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

public class Tide implements PropertyChangeListener{
	private static Tide sTide;
	private static final double SEA_LEVEL_AMPLITUDE = 6.5;
	private static final double SEA_LEVEL_AVG = 500.0;
	
	private double height;

	private Tide() {
	}

	public static Tide getInstance() {
		if (sTide == null) {
			sTide = new Tide();
		}
		return sTide;
	}

	/**
	 * @return the height
	 */
	public double getHeight() {
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(double height) {
		this.height = height;
	}

	public void update() {
		
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		int hour = Clock.getInstance().getHours();
		int minutes = Clock.getInstance().getMinutes();
		height = SEA_LEVEL_AMPLITUDE * Math.sin(((hour / 2)  * 60 + minutes) * (Math.PI/180));
		System.out.println(SEA_LEVEL_AVG + height);
		System.out.println((hour / 2) * 60 + minutes);
	}
}
